using System;
using System.ComponentModel;
using System.Data;
using System.Collections.Generic;

namespace PlacementManager
{
    public partial class CategoryComponent
    {
        /// <summary>
        /// Selects all records from the database table.
        /// </summary>
        /// <returns>A collection of objects of a type representing a row in the database table.</returns>
        [DataObjectMethodAttribute(DataObjectMethodType.Select, false)]
        public List<Category> SelectAllWVenueId(int venueId,int divisionId, string sortExpression)
        {
            List<Category> listCategory = new List<Category>();
            PlacementManager.DAL.Category_DAL o = new PlacementManager.DAL.Category_DAL();

            DataSet ds = o.SelectAllWVenueId(venueId,divisionId);

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                listCategory.Add(new Category((int)row["CategoryId"], (string)row["CategoryName"], (int)row["DivisionId"], (bool)row["IsActive"], (DateTime)row["DateCreated"], (string)row["CreatedBy"], (DateTime)row["DateUpdated"], (string)row["UpdatedBy"]));
            }

            listCategory.Sort(new CategoryComparer(sortExpression));
            return listCategory;
        }

        /// <summary>
        /// Selects all records from the database table.
        /// </summary>
        /// <returns>A collection of objects of a type representing a row in the database table.</returns>
        [DataObjectMethodAttribute(DataObjectMethodType.Select, false)]
        public List<Category> SelectAllWithoutVenueIdDivisionId(int venueId, int divisionId, string sortExpression)
        {
            List<Category> listCategory = new List<Category>();
            PlacementManager.DAL.Category_DAL o = new PlacementManager.DAL.Category_DAL();

            DataSet ds = o.SelectAllWithoutVenueIdDivisionId(venueId, divisionId);

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                listCategory.Add(new Category((int)row["CategoryId"], (string)row["CategoryName"], (int)row["DivisionId"], (bool)row["IsActive"], (DateTime)row["DateCreated"], (string)row["CreatedBy"], (DateTime)row["DateUpdated"], (string)row["UpdatedBy"]));
            }

            listCategory.Sort(new CategoryComparer(sortExpression));
            return listCategory;
        }
    }
}
